package com.yunhe.estatemanage.controller;

import com.yunhe.common.model.ResultObject;
import com.yunhe.estatemanage.domain.ProcessStatus;
import com.yunhe.estatemanage.service.ProcessStatusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: ProcessStatusController
 * @Description:
 * @author: GongDaCheng
 * @Date: 17:24 2021/9/3
 */
@Api(value = "ProcessStatus", description = "报事报修状态流程", tags = {"Model_ProcessStatus"})
@RestController
@RequestMapping(value = "/processStatus")
//@RequestMapping(value = "/yh-estatemanage/processStatus")
public class ProcessStatusController {

    @Autowired
    private ProcessStatusService processStatusService;

    @ApiOperation("新增报事报修状态流程")
    @PostMapping("/createProcessStatus")
    public ResponseEntity<ResultObject> createProcessStatus(@RequestBody ProcessStatus processStatus){
        processStatusService.create(processStatus);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("根据id删除报事报修状态流程")
    @DeleteMapping("/deleteProcessStatus")
    public ResponseEntity<ResultObject> deleteProcessStatus(@RequestParam(value = "id",required = true) int id){
        processStatusService.delete(id);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("更新报事报修状态流程")
    @PostMapping("/updateProcessStatus")
    public ResponseEntity<ResultObject> updateProcessStatus(@RequestBody ProcessStatus processStatus){
        processStatusService.update(processStatus);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("根据id查询报事报修状态流程")
    @GetMapping("/findProcessStatusById")
    public ResponseEntity<ResultObject<ProcessStatus>> findProcessStatusById(@RequestParam(value = "id",required = true) int id){
        return new ResponseEntity<>(new ResultObject(processStatusService.findById(id)),HttpStatus.OK);
    }
}
